home *** CD-ROM | disk | FTP | other *** search
- /* bt_low.c - low level functions for BTREE module */
- #include "stdio.h"
- #include "btree.h"
- #include "bt_macro.h"
-
- extern IX_DESC *pci ;
- extern BLOCK spare_block ;
-
- BLOCK *neighbor(l,direction) /* get block to right of curr. one */
- int l ; /* level to fetch neighbor on */
- int direction ; /* left or right neighbor */
- {
- RECPOS rnext ;
- int off ;
- BLOCK *pb ;
-
- pb = & spare_block ;
- l = l + 1 ; /* look in higher level index */
- retrieve_block(l,CB(l),pb,CURR) ; /* get offset on next/prev. entry */
- if( direction == RIGHTN )
- off = next_entry(pb,CO(l)) ; /* get offset of next entry */
- else
- off = prev_entry(pb,CO(l)) ; /* get offset of previous entry */
- if( off < 0 ) /* at end or beginning ? */
- return(NULL) ;
- rnext = ENT_ADR(pb,off)->rptr ; /* neighbor's block number */
- /* read it into memory */
- retrieve_block(l-1,rnext,pb,NOT_CURR) ;
- return( pb ) ; /* return it's address */
- }
-
-
- int copy_current(l,pe) /* copy current index entry */
- int l ; /* at this level */
- ENTRY *pe ; /* to this address */
- {
- BLOCK *pb ;
-
- pb = & spare_block ;
- retrieve_block(l,CB(l),pb,CURR) ; /* get curr. block */
- /* copy current entry */
- copy_entry(pe,ENT_ADR(pb,CO(l) ) ) ;
- return( IX_OK ) ;
- }
-
-
-